package com.bear.fastrepair.mvvm.ui.employee.dialog

import android.annotation.SuppressLint
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import com.bear.fastrepair.base.BaseDialog
import com.bear.fastrepair.databinding.DialogAppUpdateSelectBinding

class AppUpdateSelectDialog(
    context: Context,
    private val versionName: String = "",
    private val description: String = "",
    private val createTime: String = "",
    private val blockConfirm: (View) -> Unit
) : BaseDialog(context) {
    private lateinit var binding: DialogAppUpdateSelectBinding

    @SuppressLint("SetTextI18n")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = DialogAppUpdateSelectBinding.inflate(LayoutInflater.from(context))
        setContentView(binding.root)
        if (versionName.isNotEmpty()) {
            binding.updateDescDetail.text = "版本号：V$versionName" +
                    if (description.isNotEmpty()) "\n更新日志：$description" else "" +
                            if (createTime.isNotEmpty()) "\n更新时间：$createTime" else ""
        } else {
            binding.updateDescDetail.text = "无"
        }
        binding.cancel.setOnClickListener {
            dismiss()
        }
        binding.confirm.setOnClickListener {
            blockConfirm(it)
            dismiss()
        }
    }
}